home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / ChineseS / Xerox Font Management Utility.msi / Data1.cab / fmu.chm3 / skinsupport / madcapbody.js < prev    next >
Text File  |  2011-04-21  |  6KB  |  235 lines

  1. /// <reference path="MadCapUtilities.js" />
  2. /// <reference path="MadCapLiveHelpUtilities.js" />
  3.  
  4. // {{MadCap}} //////////////////////////////////////////////////////////////////
  5. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  6. ////////////////////////////////////////////////////////////////////////////////
  7. // <version>6.1.0.0</version>
  8. ////////////////////////////////////////////////////////////////////////////////
  9.  
  10. function FMCInit()
  11. {
  12.     if ( gInit )
  13.     {
  14.         return;
  15.     }
  16.  
  17.     //
  18.  
  19.     FMCCheckForBookmark();
  20.  
  21.     if ( FMCIsWebHelp() && window.name == "body" )
  22.     {
  23.         FMCRegisterCallback( "TOC", MCEventType.OnInit, FMCOnTocInitialized, null );
  24.     }
  25.     
  26.     if ( MCGlobals.ToolbarFrame != null )
  27.     {
  28.         FMCRegisterCallback( "Toolbar", MCEventType.OnInit, FMCOnToolbarLoaded, null );
  29.     }
  30.     
  31.     if ( MCGlobals.BodyCommentsFrame != null && !FMCIsTopicPopup( window ) )
  32.     {
  33.         if ( !FMCIsWebHelp() || MCGlobals.RootFrame != null )    // Standalone topic
  34.         {
  35.             FMCRegisterCallback( "BodyComments", MCEventType.OnLoad, FMCOnBodyCommentsLoaded, null );
  36.         }
  37.     }
  38.     
  39.     var rootFrame    = FMCGetRootFrame();
  40.  
  41.     if ( rootFrame )
  42.     {
  43.         rootFrame.FMCHighlightUrl( window );
  44.     }
  45.     else if ( typeof( FMCHighlightUrl ) != "undefined" )
  46.     {
  47.         FMCHighlightUrl( window );
  48.     }
  49.     
  50.     //
  51.  
  52.     if ( MCGlobals.RootFrame == null && !FMCIsTopicPopup( window ) )
  53.     {
  54.         var framesetLinks    = FMCGetElementsByClassRoot( document.body, "MCWebHelpFramesetLink" );
  55.         
  56.         for ( var i = 0; i < framesetLinks.length; i++ )
  57.         {
  58.             var framesetLink    = framesetLinks[i];
  59.             framesetLink.style.display = "";
  60.         }
  61.     }
  62.  
  63.     //
  64.  
  65.     if ( FMCIsLiveHelpEnabled() && !FMCIsSkinPreviewMode() )
  66.     {
  67.         gServiceClient.GetVersion( function( version )
  68.         {
  69.             var topicID    = FMCGetMCAttribute( document.documentElement, "MadCap:liveHelp" );
  70.             
  71.             if ( version == 1 )
  72.             {
  73.                 gServiceClient.LogTopic( topicID );
  74.             }
  75.             else
  76.             {
  77.                 var cshID    = CMCUrl.QueryMap.GetItem( "CSHID" );
  78.                 
  79.                 gServiceClient.LogTopic2( topicID, cshID, null, null, null );
  80.             }
  81.         }, null, null );
  82.     }
  83.  
  84.     //
  85.  
  86.     gInit = true;
  87. }
  88.  
  89. function FMCOnTocInitialized()
  90. {
  91.     if ( MCGlobals.NavigationFrame.frames["toc"].gSyncTOC )
  92.     {
  93.         FMCSyncTOC();
  94.     }
  95. }
  96.  
  97. function FMCOnToolbarLoaded()
  98. {
  99.     if ( FMCIsLiveHelpEnabled() && MCGlobals.ToolbarFrame.document.getElementById( "RatingIcons" ) != null )
  100.     {
  101.         MCGlobals.ToolbarFrame.SetRating( 0 );
  102.         
  103.         FMCUpdateToolbarRating();
  104.     }
  105.  
  106.     MCGlobals.ToolbarFrame.OnBodyInitSetCurrentTopicIndex();
  107. }
  108.  
  109. function FMCUpdateToolbarRating()
  110. {
  111.     var topicID    = FMCGetMCAttribute( document.documentElement, "MadCap:liveHelp" );
  112.  
  113.     gServiceClient.GetAverageRating( topicID, FMCBodyGetRatingOnComplete, null );
  114. }
  115.  
  116. function FMCOnBodyCommentsLoaded()
  117. {
  118.     MCGlobals.BodyCommentsFrame.TopicComments_Init( OnInit );
  119.     
  120.     function OnInit()
  121.     {
  122.         MCGlobals.BodyCommentsFrame.TopicComments_RefreshComments();
  123.     }
  124. }
  125.  
  126. function FMCBodyGetRatingOnComplete( averageRating, ratingCount, onCompleteArgs )
  127. {
  128.     var toolbarFrame    = MCGlobals.ToolbarFrame;
  129.     
  130.     toolbarFrame.SetRating( averageRating );
  131. }
  132.  
  133. function FMCCheckForBookmark()
  134. {
  135.     var hash    = document.location.hash;
  136.     
  137.     if ( !hash )
  138.     {
  139.         return;
  140.     }
  141.     
  142.     var bookmark    = null;
  143.     
  144.     if ( hash.charAt( 0 ) == "#" )
  145.     {
  146.         hash = hash.substring( 1 );
  147.     }
  148.     
  149.     var currAnchor  = null;
  150.     
  151.     for ( var i = 0; i < document.anchors.length; i++ )
  152.     {
  153.         currAnchor = document.anchors[i];
  154.         
  155.         if ( currAnchor.name == hash )
  156.         {
  157.             bookmark = currAnchor;
  158.             
  159.             break;
  160.         }
  161.     }
  162.     
  163.     if ( bookmark )
  164.     {
  165.         FMCUnhide( window, currAnchor );
  166.         
  167.         // Mozilla didn't navigate to the bookmark on load since it was inside a hidden node. So, after we ensure it's visible, navigate to the bookmark again.
  168.         
  169.         if ( !document.body.currentStyle )
  170.         {
  171.             document.location.href = document.location.href;
  172.         }
  173.         
  174.         if ( navigator.userAgent.Contains( "MSIE 7", false ) )
  175.         {
  176.             // IE 7 bug: Older builds of IE 7 have the following bug: if you create an iframe who's URL has a bookmark and the iframe's opacity has been set,
  177.             // the document won't scroll to the bookmark. It seems to be a render issue because scrolling the document in the iframe causes it to jump down to
  178.             // the bookmark and scroll from there. The hack workaround is to cause the iframe to redraw after the document has loaded, which is done here.
  179.             
  180.             window.setTimeout( function()
  181.             {
  182.                 document.body.style.display = "none";
  183.                 document.body.style.display = "";
  184.             }, 1 );
  185.         }
  186.     }
  187. }
  188.  
  189. function FMCSyncTOC()
  190. {
  191.     if ( !MCGlobals.NavigationFrame.frames["toc"] || MCGlobals.BodyFrame.document != document )
  192.     {
  193.         return;
  194.     }
  195.  
  196.     var tocPath = FMCGetMCAttribute( document.documentElement, "MadCap:tocPath" );
  197.     var href = FMCGetBodyHref();
  198.     var master = FMCGetRootFrame().FMCGetHelpSystem();
  199.     var fullTocPath = master.GetFullTocPath( "toc", href.FullPath );
  200.  
  201.     if ( fullTocPath )
  202.     {
  203.         tocPath = tocPath ? fullTocPath + "|" + tocPath : fullTocPath;
  204.     }
  205.  
  206.     MCGlobals.NavigationFrame.frames["toc"].SyncTOC( tocPath, href );
  207. }
  208.  
  209. function FMCGlossaryTermHyperlinkOnClick( node )
  210. {
  211.     var navFrame    = MCGlobals.NavigationFrame;
  212.     var anchorName    = FMCGetMCAttribute( node, "MadCap:anchor" );
  213.     
  214.     navFrame.SetActiveIFrameByName( "glossary" );
  215.     navFrame.frames["glossary"].DropDownTerm( anchorName );
  216. }
  217.  
  218. if ( gRuntimeFileType == "Topic" )
  219. {
  220.  
  221. //
  222.  
  223. if ( FMCIsDotNetHelp() || FMCIsHtmlHelp() )
  224. {
  225.     window.name = "body";
  226. }
  227.  
  228. //
  229.  
  230. var gInit    = false;
  231.  
  232. gOnloadFuncs.push( FMCInit );
  233.  
  234. }
  235.